package com.autumn.platform.auth.web.access;

import com.autumn.platform.auth.core.access.IPermission;
import com.autumn.platform.web.request.IWebRequest;

public abstract class AbstractRequestParamPermissionMapping extends AbstractWebPermissionMapping {

    private String paramName;

    @Override
    protected IPermission lookup(IWebRequest request) {
        String paramName = getParamName();
        String param = request.getNativeWebRequest().getParameter(paramName);
        return getPermission(request, param);
    }

    /**
     * 根据请求参数获取权限
     * 
     * @param request 请求信息
     * @param param 请求参数
     * @return 权限信息
     */
    protected abstract IPermission getPermission(IWebRequest request, String param);

    public String getParamName() {
        return paramName;
    }

    public void setParamName(String paramName) {
        this.paramName = paramName;
    }
}
